{extend name="base" /}

{block name="body"}
{php}use constant\Ota as OtaType;{/php}

<section class="content-header">
  <h1>
    权限列表
    <small>权限 管理</small>
  </h1>
  <ol class="breadcrumb">
    <li><a href="{:url('admin/index/index')}"><i class="fa fa-dashboard"></i> Home</a></li>
    <li class="active">权限列表</li>
  </ol>
</section>

<section class="content">
<div class="row">

{if condition="show_auth('admin/AuthRule/add')"}
  <div class="box-body">
    <a class="btn btn-block btn-success add-btn" data-url="{:url('add',['pid'=>0])}" proc-url="{:url('addProc')}">
    <i class="fa fa fa-plus-square"></i> 添加顶级权限
    </a>
  </div>
{/if}

<!--   <div class="box-body">
    <div class="col-md-6">
    <a class="btn btn-block btn-info expand-all" title="全部展开"> <i class="fa fa-plus"></i></a>
    </div>

    <div class="col-md-6">
      <a class="btn btn-block btn-danger collapse-all" title="全部收起"> <i class="fa fa-minus"></i></a>
    </div>
  </div> -->

<!-- 顶级权限 -->
{volist name="data" id="v"}
  {if condition="$v.pid == 0"}
    <div class="col-md-12">
      <div class="box box-info collapsed-box">
        <div class="box-header with-border">
          <h3 class="box-title">{$v.title} -- {$v.name} -- {$v.status? '<span class="label label-success radius">启用</span>' : '<span class="label label-danger radius">禁用</span>'}</h3>
        <div class="box-tools pull-right">

          {if condition="show_auth('admin/AuthRule/add')"}
            <a href="javascript:;" title="添加子权限" data-id="{$v.id}" data-url="{:url('add',['pid'=>$v.id])}" proc-url="{:url('addProc')}" class="btn btn-xs btn-success btn-social-icon add-btn"><i class="fa fa-plus-square"></i></a>
          {/if}

          {if condition="show_auth('admin/AuthRule/edit')"}
            <a href="javascript:;" title="编辑" data-id="{$v.id}" data-url="{:url('edit')}" proc-url="{:url('addProc')}" class="btn btn-xs btn-info btn-social-icon edit-btn"><i class="fa fa-pencil"></i></a>
          {/if}

          {if condition="show_auth('admin/AuthRule/delete')"}
            <a href="javascript:;" title="删除" data-id="{$v.id}" data-url="{:url('delete')}" class="btn btn-xs btn-danger btn-social-icon delete-btn"><i class="fa fa-trash-o"></i></a>
          {/if}

            <button type="button" class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-plus"></i>
            </button>
          </div>
          <!-- /.box-tools -->
        </div>
        <!-- /.box-header -->
        <div class="box-body">
          <!-- 子权限 -->
          {volist name="data" id="v1"}
            {if condition="$v1.pid == $v.id"}
            <div class="col-md-3">
              <div class="box box-info collapsed-box">
                <div class="box-header with-border">
                <h4 class="box-title">{$v1.title}</h4>

                  <div class="box-tools pull-right">
                   {if condition="show_auth('admin/AuthRule/edit')"}
                      <a href="javascript:;" title="编辑" data-id="{$v1.id}" data-url="{:url('edit')}" proc-url="{:url('addProc')}" class="btn btn-xs btn-info btn-social-icon edit-btn"><i class="fa fa-pencil"></i></a>
                    {/if}

                    {if condition="show_auth('admin/AuthRule/delete')"}
                      <a href="javascript:;" title="删除" data-id="{$v1.id}" data-url="{:url('delete')}" class="btn btn-xs btn-danger btn-social-icon delete-btn"><i class="fa fa-trash-o"></i></a>
                    {/if}

                    <button type="button" class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-plus"></i>
                    </button>
                  </div>
                  <!-- /.box-tools -->
                </div>
                <!-- /.box-header -->
                <div class="box-body">
                  <strong>权限名称：</strong>{$v1.name}
                </div>
                <div class="box-body">
                <strong>附加规则：</strong>{$v1.condition? $v1.condition : '--' }
                </div>
                <div class="box-body">
                  <strong>权限状态：</strong>{$v1.status? '<span class="label label-success radius">启用</span>' : '<span class="label label-danger radius">禁用</span>'}
                </div> 
                <!-- /.box-body -->
              </div>
              <!-- /.box -->
            </div>
            {/if}
          {/volist}
        </div>
        <!-- /.box-body -->
      </div>
      <!-- /.box -->
    </div>
  {/if}
{/volist}
</div>

</section>

{/block}

{block name="script"}
<script type="text/javascript" src="__AJS__/auth_rule/index.js"></script>
{/block}